MSBUILD=/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5/msbuild.exe
TYBUILD=../tybuild/bin/Release/tybuild.exe
TYSILA=../tysila2/bin/Release/tysila2.exe
PEKERNEL=bin/Release/tysos.exe
LD=x86_64-elf-ld
BZIP2=bzip2

KERNELOBJ=tysos.obj
KERNEL=tysos.bin
KERNELBZ2=tysos.bin.bz2

LDFLAGS=-pie
BZIP2FLAGS=-kf
TYSILAFLAGS=-L../mono/corlib -d --requested-module-only --extra-type _m8_mscorlib_N6_System_T6_Object_S2_1C --extra-method _m8_mscorlib_N6_System_T6_String_S2_0E_M10_get_Length_S6_200008 --extra-method _m8_mscorlib_N6_System_T6_Object_S2_1C_M5_.ctor_S6_200001 

.PHONY: clean

all: $(KERNELBZ2)

$(KERNELBZ2): $(KERNEL)
	$(BZIP2) $(BZIP2FLAGS) $(KERNEL)

$(KERNEL): $(KERNELOBJ) halt.o
	$(LD) $(LDFLAGS) -o $(KERNEL) $(KERNELOBJ) halt.o

halt.o: halt.asm
	yasm -f elf64 -o halt.o halt.asm

$(KERNELOBJ): $(TYSILA) $(PEKERNEL)
	$(TYSILA) $(TYSILAFLAGS) -o $(KERNELOBJ) $(PEKERNEL)

$(PEKERNEL): $(TYBUILD)
	$(TYBUILD) /p:Configuration=Release /v

clean:
	rm -rf obj bin $(PEKERNEL) $(KERNELOBJ) $(KERNEL) $(KERNELBZ2)

